/**
* This file is part of OntoApplications (project linked with OntoCompoFramework)
*
* Copyright (C) 2011 -  Christian Brel
*
* @author   Main    Christian Brel
**/
package applications.trimstring.ui.lib;

import java.util.Observable;

import javax.swing.JComponent;
import javax.swing.JLabel;

import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Interface;
import org.objectweb.fractal.fraclet.annotations.Requires;

@Component(provides = {@Interface(name = "jLabelItf", signature = org.objectweb.fractal.swing.JLabelItf.class), @Interface(name = "jLabelAttributes", signature = org.objectweb.fractal.swing.JLabelAttributes.class), @Interface(name = "uicontainerservice", signature = ontocompo.api.UIContainerService.class), @Interface(name = "ontocompointrospection", signature = ontocompo.api.OntoCompoIntrospection.class), @Interface(name = "observer", signature = java.util.Observer.class)})
public class TrimStringResultLabel extends JLabel implements org.objectweb.fractal.swing.JLabelItf, org.objectweb.fractal.swing.JLabelAttributes, ontocompo.api.UIContainerService, ontocompo.api.OntoCompoIntrospection, java.util.Observer {

	private String uid;
	private org.objectweb.fractal.api.Component c;
	
	@Requires(name = "trimstringservice")
	private applications.trimstring.fc.api.TrimStringService trimstringservice;
	
	@Requires(name = "trimstringobservable")
	private ontocompo.api.Observable trimstringobservable;
	
	public TrimStringResultLabel() {
		super ();
		this.uid = "applications.trimstring.ui.lib.TrimStringResultLabel";
		System.out.println(this.toString() + " created");
		//this.init();
	}
	
	@Override
	public org.objectweb.fractal.api.Component getFractalComponent() {
		// TODO Auto-generated method stub
		return this.c;
	}

	@Override
	public void setFractalComponent(org.objectweb.fractal.api.Component c) {
		// TODO Auto-generated method stub
		this.c = c;
	}

	@Override
	public JComponent getComponentItSelf() {
		// TODO Auto-generated method stub
		return this;
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		this.trimstringobservable.addObserver(this);
		
		this.setText("Null");
	}

	@Override
	public String getUid() {
		// TODO Auto-generated method stub
		return this.uid;
	}

	@Override
	public void setUid(String uid) {
		// TODO Auto-generated method stub
		this.uid = uid;
	}
	
	public String toString() {
		return "TrimStringResultLabel";
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		// TODO Auto-generated method stub
		this.update(this.trimstringservice.trim());
	}

	@Override
	public void update(Object o) {
		// TODO Auto-generated method stub
		String result = (String) o;
		this.setText(result);
	}

}
